from apscheduler.schedulers.blocking import BlockingScheduler
from apscheduler.triggers.cron import CronTrigger
from win10toast import ToastNotifier
import time
def pc_toast(header='点饭提醒',text='工作固然重要，但是也别忘记点饭哦~'):
    toaster = ToastNotifier()
    time.sleep(0.05)  # 适当休息一下，避免出现提示秒弹的情况
    toaster.show_toast(title=f"{header}", msg=f"{text}", duration=5, threaded=True, icon_path='res/maple.ico')
    while toaster.notification_active():  # toaster.notification_active()判断是否有活动通知显示
        time.sleep(0.005)
sched = BlockingScheduler()
trigger = CronTrigger(hour='14', minute='30')
sched.add_job(pc_toast, trigger)

trigger = CronTrigger(day_of_week='6',hour='20', minute='30')
sched.add_job(pc_toast, trigger,args=['作业提醒','今天是内训作业最后一天咯'])
trigger = CronTrigger(hour='20', minute='50')
sched.add_job(pc_toast, trigger,args=['下班提醒','即将下班，提前整理工作内容，按时下班哦！'])
def addjob(arr):
    weektime="以下时间段已加入开课提醒,"
    for i in arr:
        weektime+="【周"+str(int(i)+1)+"】"
        trigger = CronTrigger(day_of_week=i, hour='13', minute='30')
        sched.add_job(pc_toast, trigger, args=['开课提醒', '别忘记发开课提醒和群公告'])
        trigger = CronTrigger(day_of_week=i, hour='20', minute='30')
        sched.add_job(pc_toast, trigger, args=['课后提醒', '别忘记发课后群公告'])
    pc_toast('行课提醒',weektime)



